#!/usr/bin/perl

$list_file_name = "$ARGV[0]";

open(PNGLIST, "<", $list_file_name) or die "couldn't open $list_file_name";

$match = 0;
$total = 0;
while($line = <PNGLIST>) {
        $total++;
        ($string, $image_file_name) = split(/\s/, $line);
        $result = `./bpnet-line-ezseg ./bengali.nn $image_file_name`;
        chomp $result;
        if ($result =~ /$string/) {
                $match++;
        }
        print "$string $result $match $total\n";
}

print "accuracy: " . $match / $total * 100 . "\n";

close(PNGLIST);
